<!DOCTYPE html>
<html>
<head>
    <title>收费项目管理</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <link rel="stylesheet" type="text/css" href="../Css/pagination.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/pagination.js"></script>

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
    </style>
    <script type="text/javascript">
        $(function () {
            $('#newNav').click(function(){
                    window.location.href="charge-new.html";
             });
            //初始化数据
            initData("","");
        });
        Date.prototype.format =function(format) {
            var o = {
                "M+": this.getMonth() + 1, //month
                "d+": this.getDate(), //day
                "h+": this.getHours(), //hour
                "m+": this.getMinutes(), //minute
                "s+": this.getSeconds(), //second
                "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
                "S": this.getMilliseconds() //millisecond
            }
            if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
                (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o) if (new RegExp("(" + k + ")").test(format))
                format = format.replace(RegExp.$1,
                    RegExp.$1.length == 1 ? o[k] :
                        ("00" + o[k]).substr(("" + o[k]).length));
            return format;
        }
        function initData(hosrId,hosrName){
            $.ajax({
                url: "queryCpregister",
                data: {"hosrId":hosrId,'hosrName':hosrName},
                type: 'post',
                dataType: 'json',
                //TODO
                success: function (data){
                    //清空下级标签
                    $("#xunhuan").empty();
                    let page = data.data.cpregisterPage;
                    let param = data.data.param;
                    let list = page.list;

                    //遍历数据
                    $.each(list,function (index,cpregister){
                        let newDate = new Date(cpregister.cprTime);
                       // newDate.setTime()
                        $("#xunhuan").append(
                            "<tr >\n" +
                            "    <td style=\"vertical-align:middle;\">"+cpregister.hosrId+"</td>\n" +
                            "    <td style=\"vertical-align:middle;\">"+cpregister.hosrName+"</td>\n" +
                            "    <td style=\"vertical-align:middle;\">"+newDate.format("yyyy-MM-dd hh:mm:ss")+"</td>\n" +
                            "    <td style=\"vertical-align:middle;\"><a href=\"account-look2.html?flag=2&hosrId="+cpregister.hosrId+"\">详情</a>&nbsp;&nbsp;&nbsp; <a href=\"charge-new.html?hosrId="+cpregister.hosrId+"&hosrName="+cpregister.hosrName+"\">添加收费项</a></td>" +
                            "</tr>")

                        //查询参数回显
                        $("#hosrId").val(param.hosrId);
                        $("#hosrName").val(param.hosrName);
                        //分页
                        // $("#pageNum").text(page.pageNum+"/"+page.pages);
                        // $("#totalMsg").text(page.total);
                        /**
                         * layout 参数说明：
                         *
                         * total： 总条数
                         * sizes: 显示每页条数选择框， TODO:pageSizes参数必填,否则无法生效
                         * home： 首页按钮
                         * prev： 上一页按钮
                         * pager： 页码
                         * last： 尾页按钮
                         * next： 下一页按钮
                         * jumper： 输入框跳转（包含事件：失去焦点，回车）触发
                         *
                         * */
                        new Pagination({
                            element: '#pages',
                            type: 2,
                            layout: 'prev, pager, next, total, jumper',
                            pageIndex: 1,
                            pageSize: 5,
                            pageCount: 9,
                            total: page.total,
                            singlePageHide: false,
                            disabled: true,
                            currentChange: function(index) {
                                console.log(index);
                                $.ajax({
                                    url: "queryCpregister",
                                    data: {"pageNum":index,"hosrId":hosrId,'hosrName':hosrName},
                                    type: 'post',
                                    dataType: 'json',
                                    success: function (data){
                                        //清空下级标签
                                        $("#xunhuan").empty();
                                        let page = data.data.cpregisterPage;
                                        let param = data.data.param;
                                        let list = page.list;

                                        //遍历数据
                                        $.each(list,function (index,cpregister){
                                            let newDate = new Date(cpregister.cprTime);
                                            // newDate.setTime()
                                            $("#xunhuan").append(
                                                "<tr >\n" +
                                                "    <td style=\"vertical-align:middle;\">"+cpregister.hosrId+"</td>\n" +
                                                "    <td style=\"vertical-align:middle;\">"+cpregister.hosrName+"</td>\n" +
                                                "    <td style=\"vertical-align:middle;\">"+newDate.format("yyyy-MM-dd hh:mm:ss")+"</td>\n" +
                                                "    <td style=\"vertical-align:middle;\"><a href=\"account-look2.html?flag=2&hosrId="+cpregister.hosrId+"\">详情</a>&nbsp;&nbsp;&nbsp; <a href=\"charge-new.html?hosrId="+cpregister.hosrId+"&hosrName="+cpregister.hosrName+"\">添加收费项</a></td>" +
                                                "</tr>")

                                            //查询参数回显
                                            $("#hosrId").val(param.hosrId);
                                            $("#hosrName").val(param.hosrName);
                                        })
                                    }
                                });
                            }
                        });


                    })
                }
            });
        }
        function queryCpregister(){
            let hosrId = $("#hosrId").val();
            let hosrName = $("#hosrName").val();
            initData(hosrId,hosrName);
        }

        function resetQuery() {
            $("#hosrId").val("");
            $("#hosrName").val("");
            queryCpregister();
        }
	
    	function checkall(){
			var alls=document.getElementsByName("check");
			var ch=document.getElementById("checkall");
			if(ch.checked){
				for(var i=0;i<alls.length;i++){
					alls[i].checked=true;	
				}	
			}else{
				for(var i=0;i<alls.length;i++){
					alls[i].checked=false;	
				}	
			}
		}
		function delAll(){
			var alls=document.getElementsByName("check");
			var ids=new Array();
			for(var i=0;i<alls.length;i++){
				if(alls[i].checked){
					ids.push(alls[i].value);
				}		
			}
			if(ids.length>0){
				if(confirm("确认操作?")){
					alert("成功!");
				}
			}else{
				alert("请选中要操作的项");
			}
		}
    $(function () {       
		$('#backid').click(function(){
				window.location.href="dispensing.html";
		 });
    });
    </script>
</head>
<body>
   
<form action="#" method="post" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">病历号：</td>
        <td><input id="hosrId" type="text" name="pname" value=""/></td>
		
        <td width="10%" class="tableleft">姓名：</td>
        <td><input id="hosrName" type="text" name="pname" value=""/></td>
    </tr>
    <tr>
		
		
		  <td colspan="4">
			<center>
				<button  class="btn btn-primary" type="button" onclick="queryCpregister()">查询</button>
				<button  class="btn btn-primary" type="button" onclick="resetQuery()">清空</button>
			</center>
        </td>
    </tr>
</table>
</form>
<table class="table table-bordered table-hover definewidth m10" >
   <thead>
    <tr>
        <th>病历号</th>
        <th>姓名</th>
        <th>检查日期</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody id="xunhuan">
    <tr >
        <td style="vertical-align:middle;">1103</td>
        <td style="vertical-align:middle;">黄飞鸿</td>
        <td style="vertical-align:middle;">2015-01-04 10:34:33</td>
        <td style="vertical-align:middle;">
            <a href="account-look2.html">详情</a>
            <a href="charge-new.html">添加收费项</a>
        </td>
    </tr>
    </tbody>

		
  </table>
  
  <table class="table table-bordered table-hover definewidth m10" >
  	<tr style="height: 40px"><th colspan="5">  <div class="inline pull-right page" id="pages">
          <!--<a href='#' >第一页</a> <a href='#'>上一页</a>     <span class='current'>1</span><a href='#'>2</a><a href='/chinapost/index.php?m=Label&a=index&p=3'>3</a><a href='#'>4</a><a href='#'>5</a>  <a href='#' >下一页</a> <a href='#' >最后一页</a>
		  &nbsp;&nbsp;&nbsp;共<span id="totalMsg" class='current'>32</span>条记录<span id="pageNum" class='current'> 1/33 </span>页-->
		  </div>
		
		 
		 </th></tr>
  </table>
  
</body>
</html>
